<?php
namespace app\common\model;
use think\Db;
class WxMember extends \think\Model 
{
    public function getStatusByOpenid($openId){
        //查询openid对应的mid(会员编号)
        $wxMember = Db::name('wx_member')->where('open_id', $openId)->find();        
        if(empty($wxMember)&&$openId){
            $wx['open_id'] = $openId;
            $this ->isUpdate(false)->save($wx);
            return -1;
        }else if(empty($wxMember['mid'])){
            return  -1;
        }else {
            //查询会员状态
            $member = Db::name('member')->where('id', $wxMember['mid'])->find();
            return $member['user_status'];
        }
    }
    
}
